<?include ($_SERVER ["DOCUMENT_ROOT"] . "/lib/module/conn_db.php");?>
<?include ($_SERVER ["DOCUMENT_ROOT"] . "/lib/module/Util.php");?>
<?php //DB Open

	$result = null;
	$db = new MyDB ( false );
	$db->err_report = true;

?>
<?php

	$util = new Util();

	$condition = $_POST ["condition"];
	$words = $_POST ["words"];

	$search="";
	if($condition!="" && $words!=""){
		$search = "where ".$condition." LIKE '%".$words."%'";
	}

	$where = $search." order by category_name asc";

	$sql = " SELECT category_lft, category_sid, category_parent, category_rgt,category_hanja, category_name FROM tb_category ".$where;
	$db->query ( $sql );
	$query = $db->result;
	$total = mysql_num_rows ($query);

	$i=0;

	if($total>0){
		while($row = mysql_fetch_object($query)){

			if($row->category_parent=="1") $list[1][] = $row;
			else $list[2][] = $row;

		}
	}


?>
<?php //DB Close

	$db->close ();

?>
<? include "inc/inc_header.php" ?><!-- header -->
<?php $title = "검색"; $sub_title="검색";?>
<body style="background-repeat: repeat-x; overflow-x:hidden;" oncontextmenu="return false" onselectstart="return false" ondragstart="return false">
	<? include "inc/inc_top.php" ?><!-- top -->
	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	  <tr>
		<td style="BACKGROUND-IMAGE: url(img/surn/cont_bg04.jpg); BACKGROUND-REPEAT: repeat-x; BACKGROUND-position:right top;">&nbsp;</td>
		<td width="994" align="right" style="BACKGROUND-IMAGE: url(img/surn/cont_bg06.jpg); BACKGROUND-REPEAT: repeat-x; BACKGROUND-position:center top;padding-bottom:16px;"><table width="954" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<td style="padding-bottom:10px;"><table width="954" border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td><table width="954" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td width="10"><img src="img/surn/cont_bg08.jpg" width="10" height="36"></td>
					  <td valign="bottom" background="img/surn/cont_bg10.jpg" style="padding-left:8px;"><img src="img/sear/cont_img01.jpg" width="50" height="24"></td>
					  <td width="10"><img src="img/surn/cont_bg09.jpg" width="10" height="36"></td>
					</tr>
				</table></td>
			  </tr>
			  <tr>
				<td height="80" bgcolor="#212725" style="padding:10px 20px 0 20px;"><table width="0" border="0" cellspacing="0" cellpadding="0">
				  <tr>
					<?php $i=0;?>
					<?php if(count($list[1])>0):?>
					  <?php foreach ($list[1] as $key => $val) :?>
						<td style="padding-right:6px;"><table width="88" height="36" border="0" cellpadding="0" cellspacing="0">
							<tr>
							  <td align="center" background="img/surn/cont_img04.jpg" class="text03"><a href="surn01.php?name=<?php echo $val->category_lft;?>-<?php echo $val->category_rgt;?>"><strong><?php echo $val->category_name;?>(<?php echo $val->category_hanja;?>)</strong></a></td>
							</tr>
						</table></td>
					  <?php endforeach;?>
					<?php endif;?>
				  </tr>
				</table></td>
			  </tr>
			  <tr>
				<td><table width="954" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td width="10"><img src="img/surn/cont_bg11.jpg" width="10" height="10"></td>
					  <td height="10" background="img/surn/cont_bg13.jpg"><img src="img/surn/cont_bg13.jpg" width="10" height="10"></td>
					  <td width="10"><img src="img/surn/cont_bg12.jpg" width="10" height="10"></td>
					</tr>
				</table></td>
			  </tr>
			</table></td>
		  </tr>
		  <tr>
			<td><table width="954" border="0" cellspacing="0" cellpadding="0">
			  <tr>
				<td><table width="954" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td width="10"><img src="img/surn/cont_bg08.jpg" width="10" height="36"></td>
					  <td valign="bottom" background="img/surn/cont_bg10.jpg" class="text04" style="padding-left:8px;"><img src="img/sear/cont_img02.jpg" width="50" height="24"></td>
					  <td width="10"><img src="img/surn/cont_bg09.jpg" width="10" height="36"></td>
					</tr>
				</table></td>
			  </tr>
			  <tr>
				<td valign="top" bgcolor="#212725" class="text05" style="padding:14px 10px 4px 10px;">
					<?php if(count($list[2])>0):?>
					  <?php foreach ($list[2] as $key => $val) :?>
			  <a href="surn01_01.php?sid=<?php echo $val->category_sid;?>"><?php echo $val->category_name;?>(<?php echo $val->category_hanja;?>)</a> l
			  <?php endforeach;?>
					<?php endif;?></td>
			  </tr>
			  <tr>
				<td><table width="954" border="0" cellspacing="0" cellpadding="0">
					<tr>
					  <td width="10"><img src="img/surn/cont_bg11.jpg" width="10" height="10"></td>
					  <td height="10" background="img/surn/cont_bg13.jpg"><img src="img/surn/cont_bg13.jpg" width="10" height="10"></td>
					  <td width="10"><img src="img/surn/cont_bg12.jpg" width="10" height="10"></td>
					</tr>
				</table></td>
			  </tr>
			</table></td>
		  </tr>
		</table></td>
		<td style="BACKGROUND-IMAGE: url(img/surn/cont_bg05.jpg); BACKGROUND-REPEAT: repeat-x; BACKGROUND-position:left top;">&nbsp;</td>
	  </tr>
	</table>
	<? include "inc/inc_bottom.php" ?><!-- bottom -->
<? include "inc/inc_footer.php" ?><!-- footer -->
